package com.yotoodesign.dianba.bean;

import java.util.ArrayList;

public class SongListGroupArray {
	private int[] numberOfEachGroup;
	private String[] groupName;
	private ArrayList<SongListGroup> songListGroup = new ArrayList<SongListGroup>();
	
	public SongListGroupArray(){
		this.groupName = new String[2];
		this.groupName[0] = "我的点歌单";
		this.groupName[1] = "网友点歌单";
		
		this.numberOfEachGroup = new int[2];
		numberOfEachGroup[0] = 0;
		numberOfEachGroup[1] = 0;
		
		songListGroup.add(new SongListGroup());
		songListGroup.add(new SongListGroup());
	}
	
	public SongListGroupArray(String[] listName,
			int[] numberOfEachGroup,ArrayList<SongListGroup> songListGroup){
		this.groupName = listName;
		this.numberOfEachGroup = numberOfEachGroup;
		this.songListGroup = songListGroup;
	}
	
	public SongListGroupArray generateSamples(){
		String[] listName = {"我的点歌单","网友点歌单"};
		int[] numberOfEachGroup = {2,3};
		ArrayList<SongListGroup> groups = new ArrayList<SongListGroup>();
		for(int i = 0;i<numberOfEachGroup.length;i++){
			SongListGroup songListGroup = new SongListGroup();
			for(int j = 0;j<numberOfEachGroup[i];j++){
				SongList songList = new SongList();
				songList.setName("点歌单 "+(j+1));
				songList.setDesc("点歌单 "+(j+1)+" 的描述信息");
				songListGroup.getSongList().add(songList);
			}
			groups.add(songListGroup);
		}
		
		return new SongListGroupArray(listName,numberOfEachGroup,groups);
	}
	
	/*
	 * 添加我的点歌单
	 */
	public void addMyList(ArrayList<SongList> list){
		SongListGroup group = (SongListGroup)songListGroup.get(0);
		group.setSongList(list);
	}
	
	/*
	 * 添加网友的点歌单
	 */
	public void addOthersList(ArrayList<SongList> list){
		SongListGroup group = (SongListGroup)songListGroup.get(1);
		group.setSongList(list);
	}
	
	public String getGroupName(int groupPosition){
		return groupPosition < groupName.length ? groupName[groupPosition] : null;
	}
	
	public int getGroupCount(){
		return groupName.length;
	}
	
	public ArrayList<SongList> getGroup(int groupID){
		return songListGroup.get(groupID).getSongList();
	}
	
	
	public SongList getSongList(int groupPosition, int childPosition){
		SongList selectedSong = getGroup(groupPosition).get(childPosition);
		return selectedSong != null ? selectedSong : null;
	}

	public int[] getNumberOfEachGroup() {
		return numberOfEachGroup;
	}

	public void setNumberOfEachGroup(int[] numberOfEachGroup) {
		this.numberOfEachGroup = numberOfEachGroup;
	}


	public String[] getGroupName() {
		return groupName;
	}

	public void setGroupName(String[] groupName) {
		this.groupName = groupName;
	}

	public ArrayList<SongListGroup> getSongListGroup() {
		return songListGroup;
	}

	public void setSongListGroup(ArrayList<SongListGroup> songListGroup) {
		this.songListGroup = songListGroup;
	}
}
